﻿#region summary

// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

#endregion

using System.Diagnostics;
using NSQL.Sharpen;

namespace NSQL.Expressions
{
    [DebuggerDisplay("{ToString()}")]
    public class BetweenExpression : BaseExpression, IBetweenExpression
    {
        public IExpression Left { get; set; }
        public INumericExpression Begin { get; set; }
        public INumericExpression End { get; set; }

        public BetweenExpression()
        {
        }

        public BetweenExpression(IExpression leftExpression, INumericExpression beginExpression,
            INumericExpression endExpression)
        {
            Left = leftExpression;
            Begin = beginExpression;
            End = endExpression;
        }

        public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.Visit(this);
        public override void Accept(IExpressionVisitor visitor) => visitor.Visit(this);
        public override bool IsValid => Left != null && Left.IsValid && Begin.IsValid && End.IsValid;
        protected override IExpression DeepCopy()
        {
            return new BetweenExpression()
            {
                Left = Left.DeepClone(),
                Begin = Begin.DeepClone(),
                End = End.DeepClone(),
                Tag = Tag
            };
        }
    }
}